import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import router from './router'
import store from './store'
import echarts from 'echarts'

Vue.prototype.$echarts = echarts;
Vue.config.productionTip = false
Vue.use(ElementUI);

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')


router.beforeEach((to, from, next) => {
  if (to.matched.some(res => res.meta.requireAuth)) { // 验证是否需要登陆
    var token = localStorage.getItem('token');
    if (token) { // 查询本地存储信息是否已经登陆
      next();
    } else {
      next({
        path: '/Login', // 未登录则跳转至login页面
      });
    }
  } else {
    next();
  }
})

